/**
 * 工艺路线设计：
 * 
 * *TODO: add save widget jsplumb
 * 
 */

$(function() {
	var data = [], flowChartJson = [], widget = [];
	var editElementId = [];
	var totalData = [];

	// init function
	initFnc();
	// query btn
	$("#f1_query_btn").click(f1QueryFnc);
	// add btn
	/*$("#f6_add_btn").click(f6AddFnc);*/
	// save btn
	$("#f8_regist_btn").click(f8RegistFnc);
	// delete btn
	$("#f4_del_btn").click(f4DeleteFnc);
	// clear btn
	$("#f10_clear_btn").click(f10ClearFnc);

	$(".model").draggable({
		opacity : 0.35,
		helper : "clone"
	});

	jsPlumb.ready(function(){
		jsPlumb.setSuspendDrawing(true);
		jsPlumbLoad();
	});
	
	function jsPlumbLoad(){
		widget=new WidgetDefine();
		widget.initFunc("rightDiv");
		
		var standardAxisYValue=$("#mainDiv").css("top");
		var standardAxisY=standardAxisYValue.substring(0,standardAxisYValue.length-2);
		var mainLeftAxisX=$("#mainDiv").css("left");
		var mainRightAxisX=$("#rightDiv").css("left");
		var mainLeftAxisXValue=mainLeftAxisX.substring(0,mainLeftAxisX.length-2);
		var mainRightAxisXValue=mainRightAxisX.substring(0,mainRightAxisX.length-2);
		var standardAxisX=parseInt(mainLeftAxisXValue)+parseInt(mainRightAxisXValue);
		
		widget.drawWidget("#rightDiv",standardAxisX,parseInt(standardAxisY));

	}

	function initFnc() {
		$("input").attr({
			'disabled' : true
		});
		$("select").attr({
			'disabled' : true
		});
		$("input").val("");
		$("select").empty();
		/*initMdlCate();*/
	}
	
	function initMdlCate() {
		var outObj = baseFnc.sendXplstData("MDCT");
		SelectDom.initWithSpace($("#mdlCateSel"));
		SelectDom.addSelectArr($("#mdlCateSel"), outObj.oary, "data_ext",
				"data_desc");
	}
	
	function f1QueryFnc(){
		
	}

	function f8RegistFnc() {

	}
	
	function f4DeleteFnc(){
		
	}
	
	function f10ClearFnc() {
		$("#rightDiv").empty();
	}

})